package com.lvmama.pangolin.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.lvmama.pangolin.entity.ResultMsg;
import com.lvmama.pangolin.util.RuleUtil;

@RestController
public class ReloadSysConfigData {
	/**
	* @author zhoutianqi
	* @className ReloadSysConfigData.java
	* @date 2017年9月29日 下午4:53:07
	* @description 
	*/
	private static Logger log = Logger.getLogger(ReloadSysConfigData.class);
	@Autowired
	private RuleUtil commonUtil;
	@RequestMapping(value="/reload/roleLevel" , method = RequestMethod.POST)
    public Object reloadRoleLevel(String key){
		log.info("同步价格校验配置数据开始！");
		ResultMsg msg = new ResultMsg();
		
		try {
			//缓存价格校验时间跨度信息
	        commonUtil.cacheNormalRuleLevels();
	        //缓存价格校验特殊配置
	        commonUtil.cacheSuperRuleLevels();
	        log.info("同步价格校验门票一般级别配置数据："+commonUtil.getTicketNormalLevelList().toString());
	        log.info("同步价格校验门票特殊级别配置数据："+commonUtil.getHotelNormalLevelList().toString());
	        log.info("同步价格校验酒店一般级别配置数据："+commonUtil.getTicketSuperLevelList().toString());
	        log.info("同步价格校验酒店特殊级别配置数据："+commonUtil.getHotelSuperLevelList().toString());
	        msg.setSuccess("success");
			msg.setMessage("同步价格校验配置数据成功!");
			msg.setCode("0");
		} catch (Exception e) {
			log.info("同步价格校验配置数据失败！");
			msg.setSuccess("fail");
			msg.setMessage("同步价格校验配置数据失败!");
			msg.setCode("1");
		}
		
       return msg;
    }
	
}
